Override a global variable defined in <script> tags using a userscript
NickName:Lamp Ask DateTime:2016-12-01T09:45:41

Override a global variable defined in <script> tags using a userscript

I am trying to make a Tampermonkey userscript that needs to override a global variable that is defined in a small script in a <script> element in the HTML. This variable controls another, bigger script.

It seems that when the page loads, the global variable is first defined from the script in the HTML for a quick moment before the userscript defines it, and the big script loads after the HTML script but before the userscript. I need to have the big script load after the variable is defined to my desired value by my userscript, or it won't work.

Copyright Notice:Content Author:「Lamp」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40901296/override-a-global-variable-defined-in-script-tags-using-a-userscript

More about “Override a global variable defined in <script> tags using a userscript” related questions

Override a global variable defined in <script> tags using a userscript

I am trying to make a Tampermonkey userscript that needs to override a global variable that is defined in a small script in a &lt;script&gt; element in the HTML. This variable controls another, big...

Show Detail

global variable defined in a dll and global variable of the host software

If I have a global variable defined in a DLL that my application load, is this variable is located at the same memory region that my others global variable defined in my application (so not directl...

Show Detail

Override a global variable in javascript

I am newbie in javascript development. For my project, I am using fullcalendar package (source: fullcalendar.io) in order to display my events on a calendar by subscribing to my ical feed (ics file...

Show Detail

TypeScript global variable is not defined, declared in declare global{}

I'm trying to add a global scope variable (which means it can be accessed from anywhere without having to import/require it from another file) in TypeScript. If this is in JavaScript (NodeJS), it w...

Show Detail

Str is already defined as a global variable

I noticed something really strange while working with functions. It looks like the variable name 'str' is already defined as a global variable. Take a look: def Example(x): str = input() ret...

Show Detail

Accessing global variable defined inside a function

I am trying to understand variable scopes in Javascript and a friend asked me this question. I could use some help here. function abc(){ var a = b = 10; // a is local, b is global variable. Righ...

Show Detail

Global variable is not defined - Python

I have a problem with global variable. It returns error search = Search.Search(pattern,b) NameError: global name 'b' is not defined But I have already defined this global variable. I tried to...

Show Detail

Using a defined global variable in a collection variable

I have the following setup: A global variable api_address defined as http://apiproduction.mydomain.com. A collection variable route_address defined as users/profiles for each collection. Right no...

Show Detail

Why is this variable not defined if it is a global variable?

I create a list and try to append it to another list, but even though it is a global list it still is not defined. I had the same issue trying to apppend a string to another list, and that had th...

Show Detail

Global JSON variable override

I had to use json2.js in my project as browser(IE8) JSON object was not available for parsing strings to JSON. I ran through json2.js and am having a doubt with the variable declaration. A JSON g...

Show Detail